<template>
	<view class="tui-container">

		<!--热搜部分-->
		<view class="tui-header--banner">
			<!--banner部分-->
			<view class="tui-banner-box">
				<swiper :indicator-dots="true" :autoplay="true" :interval="5000" :duration="150" class="tui-banner--swiper" :circular="true" indicator-color="rgba(255, 255, 255, 0.8)" indicator-active-color="#fff">
					<swiper-item v-for="(item, index) in banner" :key="index" @tap.stop="detail">
						<image :src="'https://thorui.cn/images/mall/banner/' + item" class="tui-slide-image" mode="scaleToFill" />
					</swiper-item>
				</swiper>
			</view>
		</view>
		<!--搜索部分-->
		<view class="tui-header__wrap" :style="{opacity:opacity}">
			<view class="tui-rolling-search">
				<tui-icon name="search-2" :size="32" unit="rpx"></tui-icon>
				<swiper vertical autoplay circular interval="8000" class="tui-swiper">
					<swiper-item v-for="(item, index) in hotSearch" :key="index" class="tui-swiper-item" @tap="search">
						<view class="tui-hot-item">{{ item }}</view>
					</swiper-item>
				</swiper>
			</view>
		</view>
		<!-- 小菜单部分 -->
		<view class="tui-product--category">
			<view class="tui-category--item" v-for="(item, index) in category" :key="index" :data-key="item.name" @tap="more">
				<image :src="'https://thorui.cn/images/mall/category/' + item.img" class="tui-category-img" mode="scaleToFill"></image>
				<view class="tui-category-name">{{ item.name }}</view>
			</view>
		</view>
		<!-- 公告 -->
		<view class="tui-product--news">
			<tui-roll-news :list="newslist">
				<view class="tui-icon__box">
					<tui-icon name="news-fill" :size="48" unit="rpx" color='#f54f46'></tui-icon>
				</view>
			</tui-roll-news>
		</view>


		<!-- 商品列表 -->
		<view class="tui-product--box">
			<view class="tui-block--box tui-mtop__20">
				<view class="tui-group--name" @tap="more">
					<view>
						<text>工作推荐</text>
						<text class="tui-sub__desc"></text>
					</view>
					<view class="tui-more__box">
						<text>更多</text>
						<tui-icon name="arrowright" :size="36" unit="rpx" color="#999"></tui-icon>
					</view>
				</view>
			</view>
			<view class="tui-product-list">

				<block v-for="(item,index) in recomList" :key="index">
					<navigator hover-class="none"  class="recom_item">
						<view class="recom_info">
							<view class="m-list-flex">
								<!-- 公司logo -->
								<image class="img_logo" src="https://img.bhdjz.com/uploads/images/20241231/20241231180706302927091.png" mode="aspectFill"></image>
								<view class="m-cell-bd">
									<view class="recom_text">
										<view class="recom_tit">xxxxxxxx</view>
										<image src="https://img.bhdjz.com/uploads/images/20241231/20241231180706302927091.png" mode="aspectFit"></image>
									</view>
									<view class="recom_price">aaa</view>
								</view>
								<view class="order_info"  @click="bindRedPacketTap" data-index="1">
									<view class="colf">补贴</view>
									<view class="p1">
										<view class="colff7 bgf">返22元</view>
									</view>
								</view>
							</view>

							<view class="recom_type clearfix">
								<view class="recom_type_item" >xxxx</view>
								<view class="recom_type_item">bbbbb</view>
								<view class="recom_type_item">cccc</view>
								<view class="recom_type_item" >dddd</view>
							</view>
						</view>
						<view class="recom_business">
							<image src="https://img.bhdjz.com/uploads/images/20241231/20241231180706302927091.png" mode="aspectFit"></image>
							<view class="col0">dddd</view>
							<view class="col9">eeee</view>
						</view>
					</navigator>
				</block>


			</view>
		</view>

		<!--加载loadding-->
		<tui-loadmore v-if="loadding" :index="3" type="red"></tui-loadmore>
		<!-- <tui-nomore v-if="!pullUpOn"></tui-nomore> -->
		<!--加载loadding-->
		<view class="tui-safearea-bottom"></view>
	</view>
</template>
<script>
	import datalist from './index2.js'
	console.log(datalist)
	export default {
		data() {
			return {
				recomList:[1,2,3,4,5,6,7],
				newslist: [{
					id: 1,
					title: '致力发展负责任的人工智能 中国发布八大治理原则'
				}, {
					id: 2,
					title: '格兰仕暗示拜访拼多多后遭天猫打压，拼多多高层赞其有勇气'
				}, {
					id: 3,
					title: '阿里计划将每股普通股拆为8股，增加筹资灵活性'
				}],
				hotSearch: datalist.hotSearch,
				hotList: datalist.hotList,
				banner: ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg'],
				category: datalist.category,
				newProduct: datalist.newProduct,
				productList: datalist.productList,
				pageIndex: 1,
				loadding: false,
				pullUpOn: true,
				opacity: 1
			};
		},
		methods: {
			detail: function() {
				uni.navigateTo({
					url: '/pages/index/productDetail/productDetail'
				});
			},
			coupon() {
				uni.navigateTo({
					url: '/pages/index/coupon/coupon'
				});
			},
			classify: function() {
				uni.switchTab({
					url: '../classify/classify'
				});
			},
			more: function(e) {
				let key = e.currentTarget.dataset.key || '';
				uni.navigateTo({
					url: '/pages/index/productList/productList?searchKey=' + key
				});
			},
			search: function() {
				uni.navigateTo({
					url: '/pages/common/search/search'
				});
			},
			seckill(type) {
				let url = type == 1 ? '/pages/index/seckillList/seckillList' : '/pages/index/seckillDetail/seckillDetail';
				this.tui.href(url);
			},
			group(type) {
				let url = type == 1 ? '/pages/index/groupList/groupList' : '/pages/index/groupDetail/groupDetail';
				this.tui.href(url);
			}
		},
		onPullDownRefresh: function() {
			let loadData = JSON.parse(JSON.stringify(this.productList));
			loadData = loadData.splice(0, 10);
			this.productList = loadData;
			this.pageIndex = 1;
			this.pullUpOn = true;
			this.loadding = false;
			uni.stopPullDownRefresh();
		},
		onReachBottom: function() {
			if (!this.pullUpOn) return;
			this.loadding = true;
			if (this.pageIndex == 4) {
				this.loadding = false;
				this.pullUpOn = false;
			} else {
				let loadData = JSON.parse(JSON.stringify(this.productList));
				loadData = loadData.splice(0, 10);
				if (this.pageIndex == 1) {
					loadData = loadData.reverse();
				}
				this.productList = this.productList.concat(loadData);
				this.pageIndex = this.pageIndex + 1;
				this.loadding = false;
			}
		},
		onPageScroll(e) {
			// #ifdef APP-PLUS
			let scrollTop = e.scrollTop;
			if (scrollTop < 0) {
				if (this.opacity > 0)
					this.opacity = 1 - Math.abs(scrollTop) / 30;
			} else {
				this.opacity = 1
			}
			// #endif
		}
	};
</script>

<style lang="scss" scoped>
	/* components/recom_list/recom_list.wxss */
	.recom_item {
		box-shadow: 0px 1px 18px 0px rgba(0, 0, 0, 0.06);
		background-color: #fff;
		border-radius: 4rpx;
		border: 1rpx solid #EBEBEB;
		margin-bottom: 18rpx;
		padding-top: 35rpx;
		position: relative;
		overflow: hidden;
		width: 100%;
		
		.recom_text .top {
			position: absolute;
			top: 0;
			right: 0;
			width: 74rpx;
			height: 74rpx;
		}
		.recom_item:nth-last-child(1) {
			margin-bottom: 0;
		}
		.recom_tit {
			font-size: 32rpx;
			color: #333;
			font-weight: bold;
			display: inline-block;
			vertical-align: middle
		}
		.recom_price {
			font-size: 28rpx;
			color: #f21b23;
			font-weight: bold;
			padding-top: 20rpx;
		}
		.recom_type {
			padding-top: 20rpx;
		}
		.recom_type_item {
			font-size: 24rpx;
			color: #999;
			background-color: #F7F7F7;
			float: left;
			line-height: 39rpx;
			padding: 0 15rpx;
			border-radius: 8rpx;
			margin-right: 17rpx;
			margin-bottom: 17rpx;
		}
		.recom_info {
			padding: 0 30rpx 15rpx;
		}
		.clearfix {
			display: block;
		}
		.clearfix:after {
			content: "$";
			display: block;
			height: 0;
			clear: both;
			visibility: hidden;
			overflow: hidden;
		}
		.single-line {
			text-overflow: ellipsis;
			white-space: nowrap;
			overflow: hidden;
		}
		.multi-line {
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
		}
		.recom_business {
			font-size: 24rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 30rpx;
			border-top: 1rpx solid #F6F6F6
		}
		.recom_business image {
			width: 24rpx;
			height: 24rpx;
			margin-right: 7rpx;
			display: block;
		}
		.recom_business .col0 {
			color: #000;
			flex: 1;
			overflow: hidden
		}
		.recom_business .col9 {
			color: #999
		}
		.recom_text image {
			width: 32rpx;
			height: 32rpx;
			display: inline-block;
			vertical-align: middle;
			margin-left: 12rpx;
		}
		.order_info {
			text-align: center;
			line-height: 36rpx;
			background-image: linear-gradient(to right, #ffbf00, #ff7800);
			font-size: 22rpx;
			border-radius: 8rpx;
			overflow: hidden
		}
		.colff7 {
			color: #ff7100
		}
		.colf {
			color: #fff
		}
		.bgf {
			background-color: #fff;
			border-radius: 0 0 8rpx 8rpx
		}
		.order_info>view {
			width: 121rpx;
		}
		.p1 {
			padding: 1rpx;
			box-sizing: border-box
		}
		/* 组件 - flex */
		.m-list-flex {
			display: flex;
			align-items: center;
		}
		.m-list-flex .m-cell-bd {
			-webkit-box-flex: 1;
			-webkit-flex: 1;
			flex: 1;
			overflow: hidden;
		}
		.fs24 {
			font-size: 24rpx;
		}
		.recom_type {
			max-height: 106rpx;
			overflow: hidden;
		}
		.img_logo {
			margin: 0 20rpx 0 0;
			display: block;
			width: 110rpx;
			height: 110rpx;
		}
		
	}
	.tui-product--news {
		/* padding: 20rpx 20rpx 30rpx 20rpx; */
		box-sizing: border-box;
		font-size: 24rpx;
		color: #555;
	}
	page {
		background-color: #f7f7f7;
	}
	.tui-container {
		width: 100%;
		padding-bottom: 100rpx;
		color: #333;
	}
	.tui-header__wrap {
		width: 100%;
		height: 100rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
		background-color: #e41f19;
		display: flex;
		align-items: center;
		justify-content: space-between;
		/* position: fixed;
		left: 0;
		top: 0; */
		/* #ifdef H5 */
		top: 44px;
		/* #endif */
		z-index: 999;
		transition: opacity .4s;
	}
	.tui-rolling-search {
		width: 100%;
		height: 60rpx;
		border-radius: 35rpx;
		padding: 0 40rpx 0 30rpx;
		box-sizing: border-box;
		background-color: #fff;
		display: flex;
		align-items: center;
		flex-wrap: nowrap;
		color: #999;
	}
	.tui-category {
		font-size: 24rpx;
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		margin: 0;
		margin-right: 22rpx;
		flex-shrink: 0;
	}
	.tui-category-scale {
		transform: scale(0.7);
		line-height: 24rpx;
	}
	.tui-icon-category {
		line-height: 20px !important;
		margin-bottom: 0 !important;
	}
	.tui-swiper {
		font-size: 26rpx;
		height: 60rpx;
		flex: 1;
		padding-left: 12rpx;
	}
	.tui-swiper-item {
		display: flex;
		align-items: center;
	}
	.tui-hot-item {
		line-height: 26rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.tui-header--banner {
		padding-top: 20rpx;
		box-sizing: border-box;
		background: #e41f19;
	}
	.tui-hot-search {
		color: #fff;
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		box-sizing: border-box;
		position: relative;
		z-index: 2;
	}
	.tui-hot-tag {
		background-color: rgba(255, 255, 255, 0.15);
		padding: 10rpx 24rpx;
		border-radius: 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		line-height: 24rpx;
	}
	.tui-primary-bg {
		width: 50%;
		display: inline-block;
		height: 224rpx;
		border: 1px solid transparent;
		position: relative;
		z-index: 1;
		background-color: #e41f19;
	}
	.tui-route-left {
		transform: skewY(8deg);
	}
	.tui-route-right {
		transform: skewY(-8deg);
	}
	.tui-banner-box {
		width: 100%;
		padding: 0 20rpx;
		box-sizing: border-box;
		/* position: absolute; */
		/* overflow: hidden; */
		z-index: 99;
		/* bottom: 00rpx; */
		/* left: 0; */
	}
	.tui-banner--swiper {
		width: 100%;
		height: 240rpx;
		border-radius: 20rpx;
		overflow: hidden;
		transform: translateY(0);
		background-color: #f8f8f8;
	}
	.tui-slide-image {
		width: 100%;
		height: 350rpx;
		border-radius: 20rpx;
		display: block;
	}
	/* #ifdef MP-WEIXIN */
	.tui-banner--swiper .wx-swiper-dot {
		width: 8rpx;
		height: 8rpx;
		display: inline-flex;
		background: none;
		justify-content: space-between;
	}
	.tui-banner--swiper .wx-swiper-dot::before {
		content: '';
		flex-grow: 1;
		background-color: rgba(255, 255, 255, 0.8);
		border-radius: 16rpx;
		overflow: hidden;
	}
	.tui-banner--swiper .wx-swiper-dot-active::before {
		background-color: #fff;
	}
	.tui-banner--swiper .wx-swiper-dot.wx-swiper-dot-active {
		width: 16rpx;
	}
	/* #endif */
	/* #ifndef MP-WEIXIN */
	::v-deep .tui-banner--swiper .uni-swiper-dot {
		width: 8rpx;
		height: 8rpx;
		display: inline-flex;
		background-color: none;
		justify-content: space-between;
	}
	::v-deep .tui-banner--swiper .uni-swiper-dot::before {
		content: '';
		flex-grow: 1;
		background-color: rgba(255, 255, 255, 0.8);
		border-radius: 16rpx;
		overflow: hidden;
	}
	::v-deep .tui-banner--swiper .uni-swiper-dot-active::before {
		background-color: #fff;
	}
	::v-deep .tui-banner--swiper .uni-swiper-dot.uni-swiper-dot-active {
		width: 16rpx;
	}
	/* #endif */
	.tui-product--category {
		padding: 20rpx 20rpx 30rpx 20rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		font-size: 24rpx;
		color: #555;
		/* margin-bottom: 20rpx; */
	}
	.tui-category--item {
		width: 20%;
		height: 118rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-direction: column;
		padding-top: 30rpx;
	}
	.tui-category-img {
		height: 80rpx;
		width: 80rpx;
		display: block;
	}
	.tui-category-name {
		line-height: 24rpx;
	}
	.tui-block--box {
		width: 100%;
		padding: 0 25rpx 25rpx;
		box-sizing: border-box;
		background-color: #ffffff;
		border-radius: 20rpx;
		overflow: hidden;
	}
	.tui-product--box {
		margin-top: 20rpx;
		padding: 0 25rpx;
		box-sizing: border-box;
	}
	.tui-img__coupon {
		width: 100%;
		height: 184rpx;
		display: block;
	}
	.tui-mtop__20 {
		margin-top: 20rpx;
	}
	.tui-bg-white {
		background-color: #fff;
	}
	.tui-group--name {
		width: 100%;
		font-size: 34rpx;
		line-height: 34rpx;
		font-weight: bold;
		text-align: center;
		padding: 30rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #333;
	}
	.tui-sub__desc {
		color: #34c7a9;
		font-size: 28rpx;
		font-weight: 400;
		padding-left: 25rpx;
	}
	.tui-color__pink {
		color: #EF1346;
	}
	.tui-seckill__box {
		display: flex;
		align-items: center;
	}
	.tui-seckill__img {
		width: 160rpx;
		height: 34rpx;
	}
	.tui-countdown__box {
		width: 228rpx;
		display: flex;
		align-items: center;
		color: #fff;
		background-color: #fff;
		font-weight: 400;
		border: 1px solid #eb0909;
		height: 40rpx;
		border-radius: 30px;
		overflow: hidden;
		margin-left: 25rpx;
	}
	.tui-countdown__title {
		width: 100rpx;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #eb0909;
		flex-shrink: 0;
		font-size: 24rpx;
		line-height: 24rpx;
	}
	.tui-flex__center {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	/*秒杀商品*/
	.tui-goods__list {
		display: flex;
		align-items: center;
	}
	.tui-goods__item {
		background-color: #fff;
		width: 150rpx;
		height: 230rpx;
		border-radius: 6rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		flex-shrink: 0;
		margin-right: 18rpx;
	}
	.tui-goods__imgbox {
		width: 150rpx;
		height: 150rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
	}
	.tui-goods__img {
		max-width: 150rpx;
		max-height: 150rpx;
		display: block;
	}
	.tui-pri__box {
		max-width: 150rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.tui-sale-pri {
		display: flex;
		align-items: flex-end;
		padding: 10rpx 0 8rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		line-height: 28rpx;
		color: #eb0909;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}
	.tui-size-sm {
		font-size: 24rpx;
		line-height: 24rpx;
		transform: scale(0.8);
		transform-origin: 0 50%;
	}
	.tui-original__pri {
		font-size: 24rpx;
		line-height: 24rpx;
		color: #999999;
		transform-origin: center 10%;
		transform: scale(0.8);
		display: flex;
		align-items: center;
		justify-content: center;
		text-decoration: line-through;
	}
	/*秒杀商品*/
	.tui-more__box {
		display: flex;
		align-items: center;
		font-weight: 400;
		color: #999;
	}
	.tui-more__box text {
		font-size: 24rpx;
		line-height: 24rpx;
	}
	.tui-new-box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
	}
	.tui-new-item {
		width: 49%;
		height: 180rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		background: #f5f2f9;
		position: relative;
		border-radius: 12rpx;
	}
	.tui-new-mtop {
		margin-top: 2%;
	}
	.tui-title-box {
		font-size: 24rpx;
	}
	.tui-new-title {
		font-size: 26rpx;
		line-height: 32rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}
	.tui-new-price {
		padding-top: 18rpx;
	}
	.tui-new-present {
		color: #ff201f;
		font-weight: bold;
	}
	.tui-new-original {
		display: inline-block;
		color: #a0a0a0;
		text-decoration: line-through;
		padding-left: 12rpx;
		transform: scale(0.8);
		transform-origin: center center;
	}
	.tui-new-img {
		width: 148rpx;
		height: 148rpx;
		display: block;
		flex-shrink: 0;
	}
	.tui-new-label {
		width: 56rpx;
		height: 56rpx;
		border-top-left-radius: 12rpx;
		position: absolute;
		left: 0;
		top: 0;
	}
	.tui-title__img {
		width: 100%;
		padding: 30rpx 0;
		display: flex;
		justify-content: center;
	}
	.tui-title__img image {
		width: 352rpx;
		height: 32rpx;
	}
	.tui-product-list {
		display: flex;
		justify-content: space-between;
		flex-direction: row;
		flex-wrap: wrap;
		box-sizing: border-box;
		/* padding-top: 20rpx; */
	}
	.tui-product-container {
		flex: 1;
		margin-right: 2%;
	}
	.tui-product-container:last-child {
		margin-right: 0;
	}
	.tui-pro-item {
		width: 100%;
		margin-bottom: 4%;
		background: #fff;
		box-sizing: border-box;
		border-radius: 12rpx;
		overflow: hidden;
	}
	.tui-pro-img {
		height: 294rpx;
		width: 100%;
		display: block;
	}
	.tui-pro-content {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 20rpx;
	}
	.tui-pro-tit {
		color: #2e2e2e;
		font-size: 26rpx;
		line-height: 32rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}
	.tui-pro-price {
		padding-top: 18rpx;
	}
	.tui-sale-price {
		font-size: 34rpx;
		font-weight: 500;
		color: #e41f19;
	}
	.tui-factory-price {
		font-size: 24rpx;
		color: #a0a0a0;
		text-decoration: line-through;
		padding-left: 12rpx;
	}
	.tui-pro-pay {
		padding-top: 10rpx;
		font-size: 24rpx;
		color: #656565;
	}
</style>